In [1]:
import numpy as np
from numpy import linalg
import numpy.random as npr
import pylab as pl
%matplotlib inline
Based on "Intermolecular and surface forces" (Israelchvili, 2003)
In [2]:
mie = lambda r,A=1,B=2,n=6,m=12: B/(r**m)-A/(r**n)
In [16]:
LJ = lambda r,A=10,B=1: (B/(r**12))-(A/(r**6))
In [33]:
LJ_f = lambda r,A=10,B=1: -12*(B/(r**13))+6*(A/(r**7))
In [36]:
x = np.linspace(0.1,0.2,500)
A = 1e-7
B = 1e-13
pl.plot(x,LJ(x,A,B))
#pl.plot(x,-LJ_f(x,A,B))
Out[36]:
In [37]:
pl.plot(x,-LJ_f(x,A,B))
Out[37]:
In [154]:
n = 100000
R = 1
rho = 1
r = 0
dim = 2
points = npr.rand(n,dim)*2*R - R # initially consider a cube instead of a sphere
force = lambda r,m1=1,m2=2,G=1: -G*m1*m2/r
dist = lambda x1,x2: np.sqrt(sum((x1-x2)**2))
p = np.zeros(dim)
p[0] = r
forces = np.array([force(dist(p,x)) for x in points])
In [155]:
dist(p,points[0])
Out[155]:
In [153]:
pl.hist(forces,bins=50,log=True);
In [129]:
force(1)
Out[129]:
In [51]:
p[0] = r
In [ ]: